<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var arr = [7, 1, 5, 3, 6, 4];
        var min = arr[0];
        var minIndex = 0;
        for (i = 0; i < arr.length; i++) {
            // 求最小值和下标
            if (min > arr[i]) {
                min = arr[i];
                minIndex = i;
            }
        }
        arr.splice(0,minIndex+1);
        for (i = 0; i < arr.length; i++) {
            //求剩下的数组的最大值
            var max = arr[0];
            if (max < arr[i]) {
                max = arr[i];
                console.log(max - min);
            }
        }
    </script>
</head>

<body>

</body>

</html>